<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css">
    <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
    <script type="text/javascript" src="http://unpkg.com/view-design@4.0.2/dist/iview.min.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>总数:{{total}}</p> 

        <my-component v-model="total"></my-component>
        <button @click="handleReduce">-1</button>
    </div>
    <script>
        Vue.component('my-component',{
            props:['value'],
            template:"<input :value='value' @input='updateValue'/>",
            data:function(){
                return {
                    counter:0
                }
            },
            methods:{
                updateValue:function(){
                    this.counter++
                    this.$emit('input',this.counter);
                }
            }
        })

        new Vue({
            el:"#app",
            data:{
                total:0
            },
            methods:{
                handleReduce:function(){
                    this.total--;
                }
            }
        })

    </script>
</body>
</html>